package com.etc.dao;

import com.etc.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

@Repository
public interface UserDao extends JpaRepository<User, Integer>, JpaSpecificationExecutor<User>, Serializable {
    @Query("select u from User u  where u.usertel = ?1")
    User findByUserTel(String usertel);

    @Query("select u from User u where u.username=?1")
    User findByUsername(String username);

    @Query("select u from User u where u.username=?1 and u.userpassword=?2")
    User findByUsernameAndUserpassword(String username, String userpassword);
    /**
     * 后台用户模糊查询（李添杭）
     * @param content 模糊查询的字段
     * @param pageable
     * @return
     */
    @Query(value = "select u from User u where u.username like %?1%")
    public Page<User> findByLike(String content, Pageable pageable);

    /*@Query(value = "select u from User u join Record r on where u.username like %?1%")
    public Page<User> findByLike1(String content, Pageable pageable);*/


}